import 'package:flutter/material.dart';

class RadioPage extends StatefulWidget {
  @override
  _RadioPageState createState() => _RadioPageState();
}

class _RadioPageState extends State<RadioPage> {
  int _sex = 1;
  int _radio = 1;
  bool _switch = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('radio'),
      ),
      body: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              Text('男:'),
              Radio(
                value: 1,
                onChanged: (v) {
                  setState(() {
                    this._sex = v;
                  });
                },
                groupValue: this._sex,
              ),
              Text('女:'),
              Radio(
                value: 2,
                onChanged: (v) {
                  setState(() {
                    this._sex = v;
                  });
                },
                groupValue: this._sex,
              ),
              SizedBox(height: 40,)
            ],
          ),
          RadioListTile(
            title: Text('标题'),
            subtitle: Text('副标题'),
            value: 1,
            groupValue: this._radio,
            selected: this._radio ==1,
            onChanged: (v){
              setState(() {
                this._radio = v;
              });
            },
            secondary: Image.network('https://www.itying.com/images/flutter/6.png'),
          ),
          RadioListTile(
            title: Text('标题1'),
            subtitle: Text('副标题1'),
            value: 2,
            groupValue: this._radio,
            selected: this._radio ==2,
            onChanged: (v){
              setState(() {
                this._radio = v;
              });
            },
          ),
          SizedBox(height: 40,),
          Switch(
            value: this._switch,
            onChanged: (v) {
              setState(() {
                this._switch = v;
              });
            },
          )
        ],
      ),
    );
  }
}
